Skip to content

Develop#215

Open
ZAKANDRE wants to merge 7 commits intomate-academy:masterfrom
ZAKANDRE:develop
Open

Develop#215
ZAKANDRE wants to merge 7 commits intomate-academy:masterfrom
ZAKANDRE:develop

Conversation

@ZAKANDRE
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Great job on this submission! The server is well-structured and correctly uses streams for processing. However, a change is needed to meet all the requirements.

The primary issue is that the compressed file names have the wrong extensions.

  • Required: .gz for gzip and .dfl for deflate.
  • Current: .gzip and .deflate.

Please update the logic in src/createServer.js to map the compressionType to the correct extension when you set the Content-Disposition header.

As a minor improvement, you could also add the required attribute to the <select> element in src/index.html for better client-side validation. After you fix the file extension issue, I'll be happy to approve your work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


res.writeHead(200, {
'Content-Type': contentType,
'Content-Disposition': `attachment; filename=${filename}.${compressionType}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task description specifies the file extensions should be .gz for gzip and .dfl for deflate. Currently, you are using the compressionType variable directly, which results in .gzip and .deflate extensions. You should map the compression type to the correct extension.

method="POST"
enctype="multipart/form-data"
>
<select name="compressionType">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding the required attribute to this select element. This would prevent the form from being submitted if the user hasn't chosen a compression type, which improves the user experience by providing instant client-side validation.

<title>Document</title>
</head>
<body>
<form action="http://localhost:5700/compress"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action attribute is hardcoded to a specific URL. It's better practice to use a relative path like /compress to make the form independent of the server's host and port. Additionally, please note that the server implementation is configured to serve the file located at src/index.html, not this one.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Great job on fixing the server-side logic for file extensions from the last review!

However, this submission requires changes because the core compression functionality is broken for gzip and deflate. There is a mismatch between the values sent from your HTML form and the values your server expects.

  • In src/index.html, the <option> tags for gzip and deflate have value="gz" and value="dfl".
  • Your server logic in src/createServer.js correctly expects the full names: "gzip" and "deflate".

This causes the server to reject these requests with an 'Unsupported compression type' error. Please update the value attributes in src/index.html to match the full names. Once that's fixed, your project should be all set!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/index.html Outdated
Comment on lines +15 to +17
<option value="gz">gzip</option>
<option value="dfl">deflate</option>
<option value="br">br</option>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value attributes for these options should be gzip, deflate, and br respectively. The server-side logic in createServer.js checks for these full names to determine which compression algorithm to use. Currently, you are sending the extensions (gz, dfl), which will cause the server to respond with an 'Unsupported compression type' error.

Comment on lines +71 to +84
if (compressionType === 'gzip') {
compressStream = zlib.createGzip();
contentType = 'application/gzip';
} else if (compressionType === 'deflate') {
compressStream = zlib.createDeflate();
contentType = 'application/zlib';
} else if (compressionType === 'br') {
compressStream = zlib.createBrotliCompress();
contentType = 'application/brotli';
} else {
res.statusCode = 400;

return res.end('Unsupported compression type');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block correctly checks for 'gzip', 'deflate', and 'br'. However, the src/index.html file is sending different values ('gz', 'dfl') from its form for gzip and deflate options. This mismatch will cause requests for gzip and deflate compression to fail with an 'Unsupported compression type' error. Please ensure the value attributes in the <option> tags in src/index.html match the values expected by the server.

Copy link
Copy Markdown

@Anton-Kuchmasov Anton-Kuchmasov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants